package com.jxc.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/PrintSum")
public class PrintSum extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // 这里要注意得到的result的数据类型
        int result = (Integer)req.getAttribute("result");

        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().print("<h1>计算结果："+result+"</h1>");
    }
}
